
import 'package:flutter/material.dart';
import 'package:wis_flutter/home.dart';
import 'package:wis_flutter/wis_component/notification/notificationModel.dart';

class NotificationPage extends StatefulWidget{
  @override
  _NotificationPage createState() => _NotificationPage();
}

class _NotificationPage extends State<NotificationPage> {

  @override
  Widget build(BuildContext context) {
    return  Scaffold(
        appBar: AppBar(
          title: Text('Notification example'),
        ),
        body: SingleChildScrollView(
          scrollDirection: Axis.vertical,
          child: Padding(
            padding: EdgeInsets.all(8.0),
            child: Center(
              child: Column(
                children: <Widget>[
                  PaddedRaisedButton(
                    buttonText: '默认消息提醒',
                    onPressed: () async {
                      await showDefaultNotification();
                    },
                  ),
                  PaddedRaisedButton(
                    buttonText: '大文本消息提醒',
                    onPressed: () async {
                      await showBigTextNotification();
                    },
                  ),
                  PaddedRaisedButton(
                    buttonText: '消息提醒携带图片',
                    onPressed: () async {
                      await showPictureNotification();
                    },
                  ),
                ],
              ),
            ),
          ),
        ),
      );

  }
  // 默认消息提醒
  showDefaultNotification(){

    notificationManage.createDefaultNotification(
        NotificationModel(
            id: 0,
            title:"测试",
            body:"消息提醒测试",
            successNotification:(NotificationModel model)=>{
              debugPrint("美丽！！")
            }
        ));
  }
  showBigTextNotification(){
    notificationManage.createBigTextNotification(
        NotificationModel(
            id: 0,
            title:"测试",
            body:"上海西信信息科技股份有限公司成立于2004年，注册资本人民币2500万元，2017年成功在新三板上挂牌。作为一家企业智能制造、数字化转型综合系统提供商，已经具备了服务大中型客户的企业级C2M整体解决方案的交付能力。"
                "业务覆盖全国并已进行国际化全球交付，在成都、深圳、长沙、及澳大利亚悉尼等地均设有分、子公司。西信信息立足核心的信息化咨询业务、发展软件及工业互联网平台建设，逐步向信息化与自动化技术高度融合与集成的业务方向发展，为制造型企业提供智能制造和数字化转型所需的核心系统建设服务。",
            successNotification:(NotificationModel model)=>{
              debugPrint("美丽！！")
            }
        ));
  }
  showPictureNotification(){
    notificationManage.createPictureNotification(
        NotificationModel(
            id: 0,
            title:"测试",
            body:"图片测试",
            resourcePath:"http://demo.westinfosoft.com/mesv2/resources/images/pc/background/login-bg.png",
            successNotification:(NotificationModel model)=>{
              debugPrint("美丽！！")
            }
        ));
  }
}

class PaddedRaisedButton extends StatelessWidget {
  final String buttonText;
  final VoidCallback onPressed;

  const PaddedRaisedButton({
    @required this.buttonText,
    @required this.onPressed,
  });

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: EdgeInsets.fromLTRB(0.0, 0.0, 0.0, 8.0),
      child: RaisedButton(child: Text(buttonText), onPressed: onPressed),
    );
  }
}